import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-09-24
 * Time:10:21
 */
@WebServlet("/one")
public class Java_1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf8");
        StringBuilder str1=new StringBuilder();

        str1.append(req.getProtocol());
        str1.append("<br>");

        str1.append(req.getMethod());
        str1.append("<br>");

        str1.append(req.getRequestURI());
        str1.append("<br>");

        str1.append(req.getContextPath());
        str1.append("<br>");

        str1.append(req.getQueryString());
        str1.append("<br>");

        Enumeration<String> headers=req.getHeaderNames();
        while(headers.hasMoreElements()){
            String header=headers.nextElement();
            str1.append(header+":"+req.getHeader(header));
            str1.append("<br>");
        }
       /* 设置状态码
        resp.sendError(500);*/
        resp.sendRedirect("https://blog.csdn.net/m0_74097410/article/details/127451913?spm=1001.2014.3001.5502");
        resp.setHeader("refresh","10");
       /* 设置刷新时间
        resp.setHeader("refresh","2");*/
    /*    resp.getWriter().write(str1.toString());
        resp.getWriter().write("我喜欢你");*/
    }
}
